global tcl_interactive tcl_prompt1 tcl_prompt2
global tcl_platform count
# $Id: tclshrc.tcl 83306ac00e39 2013/03/03 02:04:53 pgurumur $
# Copyright (c) 2009 Prabhu Gurumurthy  <pgurumur@gmail.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# __version__  = "$Revision: 83306ac00e39 $"
# __author__   = "$Author: pgurumur $"
# __modified__ = "$Date: 2013-03-03 02:04:53Z $"
#
# Configure the prompt according to the actual (non-wish) running
# First, only bother with a prompt IF it is an interactive shell
# We may wish to source from other scripts just for convenience

set banner "
 .-') _                      
(  OO) )                     
/     '._  .-----. ,--.      
|'--...__)'  .--./ |  |.-')  
'--.  .--'|  |('-. |  | OO ) 
   |  |  /_) |OO  )|  |`-' | 
   |  |  ||  |`-'|(|  '---.' 
   |  | (_'  '--'\ |      |  
   `--'    `-----' `------' 
"
if {[info exists tcl_interactive] && $tcl_interactive > 0} {
   set var [split [info hostname] .]
   set host [lindex $var 0]
   set os $tcl_platform(os)
   set mach $tcl_platform(machine)
   puts "TCL version $tcl_version on $os platform $mach"
   puts "Library: $tcl_library\n"
   puts $banner
   set prompt [format "(%s) \[%s:%s\]> " $os $mach $tcl_patchLevel]
   exec stty erase 
   # puts -nonewline "= $tcl_platform(user) =\n$prompt: $tcl_version > "
   set tcl_prompt1 { puts -nonewline $prompt }
   set tcl_prompt2 {puts -nonewline "continue > "}
   if {[info exists itcl::patchLevel]} {
      set tcl_prompt1 {puts -nonewline "=========\nitclsh$::itcl::patchLevel > "}
      set tcl_prompt2 {puts -nonewline "continue > "}
   } elseif [string match exp_version [info command exp_version]] {
      set tcl_prompt1 {puts -nonewline "========\nexpect[exp_version] > "}
      set tcl_prompt2 {puts -nonewline "continue > "}
   } elseif {[info exists tnm(version)]} {
      set tcl_prompt1 {global tnm
         puts -nonewline "=========\nscotty$tnm(version) > "}
      set tcl_prompt2 {puts -nonewline "  continue >  "}
   } elseif {[llength [info commands pg_connect]] > 0} {
      regsub {tclsh} $tcl_prompt1 {pgtclsh}
   }

}

# Convenience procs
proc showenv {} {
   global env
   foreach k [lsort [array names env]] {
      puts "$k=\"$env($k)\""
   }
}
